package com.core.family.gen.api;


import com.core.common.domain.response.R;
import com.core.family.gen.config.GenProperties;
import com.core.family.gen.config.GenConfManger;
import com.core.family.gen.domain.po.TableBeanPo;
import com.core.family.gen.service.gen.IGenHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController()
@RequestMapping("/api/code/generator")
public class GeneratorApiController {


    boolean useDefaultConfig = true;

    @Autowired
    IGenHandler generatorService;

    @Autowired
    GenConfManger config;


    @GetMapping("/tablesList")
    List<TableBeanPo> list() throws Exception {

        generatorService.setConfig(config);
        List<TableBeanPo> list = generatorService.tablesList();
        return list;
    }

    @RequestMapping("/genCode")
    public R genCode(@RequestBody List<TableBeanPo> tableNames) throws Exception {

        generatorService.setConfig(config);
        generatorService.genCode(tableNames);
        return R.ok();

    }

}
